/*
 * Copyright (C) 2000-2004 Technical University of Ilmenau, Germany
 *                         Department of Electronic Circuits & Systems
 *
 * You may only use this file according to the terms of the license agreement included
 * within the file LICENSE which is distributed together with the software package.
 *
 * CVS Info:
 * $Author: rummler $
 * $Date: 2004/03/10 20:19:51 $
 * $Revision: 1.1.2.1 $
 * $State: Exp $
 * $RCSfile: TrivialEvaluator.java,v $
 *
 */
package elka.isi.operator;

import elka.isi.individual.AnimalIndividual;
import elka.isi.util.RWUtils;

import org.evolvica.core.IIndividual;
import org.evolvica.core.IIndividualSet;
import org.evolvica.core.ISetIterator;
import org.evolvica.core.eval.AbstractEvaluator;

/** Trivial evaluator example.
 *
 * @author Andreas Rummler
 * @since 0.4.0
 * @version $Revision: 1.1.2.1 $ $Date: 2004/03/10 20:19:51 $
 */
public class RWEvaluator extends AbstractEvaluator {

	/**
	 * @see org.evolvica.core.eval.AbstractEvaluator#evaluate(org.evolvica.core.IIndividual)
	 */
	protected int rabbitsInPopulation;
	protected int roesInPopulation;
	protected int wolvesInPopulation;
	
	public void evaluate(IIndividual ind) {

		AnimalIndividual animal = (AnimalIndividual) ind;
		animal.evaluate(rabbitsInPopulation,roesInPopulation,wolvesInPopulation);

	}

	public Object process(Object input) {
		rabbitsInPopulation = (RWUtils.getRabbits((IIndividualSet) input)).size();
		roesInPopulation = (RWUtils.getRoes((IIndividualSet) input)).size();
		wolvesInPopulation = (RWUtils.getWolves((IIndividualSet) input)).size();
		for (ISetIterator it = ((IIndividualSet) input).iterator();
			it.hasNext();
			) {
			evaluate((IIndividual) it.next());
		}
		return input;
	}
	
}
